import {AcceptedPlugin} from 'postcss'
let ui_width = 1920
export default function xwPx2vw():AcceptedPlugin {
    return {
        postcssPlugin: 'vite-plugin-xw-px2vw',
        prepare: (res) => {
            return {
                AtRule: (node) => {
                    const {nodes, params} = node
                    // console.log( '!!!!!!!!', params);
                    // nodes.forEach(el => {
                    //     console.log(el?.prop, el.value);
                    // });
                },
                Declaration: (node) => {
                    const {prop, value} = node
                    // console.log(prop,'__',value);
                    if(value.includes('xwfont')) {
                        const curFont = parseFloat(value)
                        node.value = ((curFont / ui_width) * 100).toFixed(2) +'vw'
                    }
                }
            }
        }
    }
}